<?php

require("./config.php");

if (!isset($_POST['req'])) {
    die("No request provided.");
} else {

    if (filter_input(INPUT_POST, 'req') == "obtieneAnnos") {

        $json = array("success" => false, "rowCount" => 0, "Elements" => Array());

        $query = "SELECT DISTINCT AÑO_GRUPO_CURSO FROM GRUPO_CURSO;";

        $result = $dbConn->query($query);
        $i = 0;
        while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
            array_push($json['Elements'], $row);
            $i++;
        }

        if ($i > 0) {
            $json['success'] = true;
            $json['rowCount'] = $i;
        }
        print(json_encode($json));
    }
}


